home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000157_icon-group-sender _Sun Jul 18 15:23:12 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id PAA07496
for icon-group-addresses; Sun, 18 Jul 1999 15:22:58 -0700 (MST)
Message-Id: <199907182222.PAA07496@baskerville.CS.Arizona.EDU>
To: icon-group@optima.CS.Arizona.EDU
Date: Thu, 15 Jul 1999 21:08:44 -0500
From: memphis@macconnect.com (Garry)
Subject: [Q][newbie] Why use a useless loop?
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
There is a wonderful little procedure, lastname(s), in the Icon Library
for extracting the last name from a string s representing a person's
full name. (It seems wonderful to me considering how compact yet
tolerant it is, and how I would write it in other languages <ugh>).
e.g. lastname("Dr. I. M. Zany, Jr.") produces a "Zany" result.
The implementation is
# File: lastname.icn
# Subject: Procedure to produce last name
# Author: Ralph E. Griswold
# Date: April 30, 1993
#
# Produces the last name of a name in conventional form. Obviously, it
# doesn't work for every possibility.
procedure lastname(s)
local line, i
while line := trim(s) do {
line ?:= tab(upto(',')) # Get rid of things like " ... , Jr."
line ? {
every i := upto(' ')
tab(\i + 1)
return tab(0)
}
}
end
My problem is that I can't think of any reason for writing
while line := trim(s) do { ... }
instead of just
line := trim(s)
Can anyone see a need for the "while"? If so, please teach me. I did of
course already spend more than one full minute thinking about this and
looked up trim() in the Icon book. Maybe there really is no need for the
"while" but then I've observed that I'm blind to my blind spots.
--
Garry
Tech Writer & Freelance Programmer